import { h } from "vue";
import type { ConfigItem } from "./index.d";
import { ElDatePicker } from "element-plus";

const DatePicker = (item: ConfigItem, data: any) => {
  return h(ElDatePicker, {
    clearable: true,
    type: "daterange",
    "range-separator": "至",
    "start-placeholder": "开始日期",
    "end-placeholder": "结束日期",
    "value-format": "YYYY-MM-DD",
    modelValue: data[item.prop],
    "onUpdate:modelValue": (newValue: any) => {
      data[item.prop] = newValue;
    }
  });
};

export default DatePicker;
